package com.example.mobilesafe.interception.service;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;

import androidx.annotation.Nullable;

import com.example.mobilesafe.interception.reciever.InterceptCallReciever;

public class InterceptionService extends Service {
    private InterceptCallReciever receiver;
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        IntentFilter recevierFilter = new IntentFilter();
        recevierFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL);
        recevierFilter.addAction("android.intent.action.PHONE_STATE");
        //此处可能有错误，在教程第154页
        receiver = new InterceptCallReciever();
        registerReceiver(receiver,recevierFilter);
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unregisterReceiver(receiver);
    }
}
